<?php
/**
 * Description of Addsite
 *
 * @author Admin
 */
class Application_Form_Addsite extends Zend_Form 
{
    public function init() {
        $this->setName('addsite');

        $url = new Zend_Form_Element_Text('url');
        $url->setLabel('url')
                ->setRequired(true)
                ->addValidator('NotEmpty')
                ->addFilter('StripTags')
                ->addFilter('StringTrim');


        $category = new Zend_Form_Element_Select('category');
        $obj = new Pub_Model_Publisher();              
        $category->setLabel('category');  
        //выборка всех родительских категорий
        foreach ($obj->getAllParentCategories() as $parent) {
            $category->addMultiOption($parent['name']);
            //выборка дочерних категорий
            foreach ($obj->getAllChildCategories($parent['id']) as $child) {
                $category->addMultiOption($child['id'], $child['name']);                
            }
        }
        
        $keywords = new Zend_Form_Element_Text('keywords');
        $keywords->setLabel('keywords');
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Add site');
        
        $this->setElements(array($url, $category, $keywords, $submit));
    }    
}

?>
